package com.zmc.coupon.config.mq;


import com.zmc.common.constant.QueueConstant;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author zmc
 * 延时关单
 */
@Configuration
public class CouponReduceQueueConfig {


    @Bean("couponReduceExchange")
    public Exchange orderExchange() {
        return new TopicExchange(QueueConstant.COUPON_REDUCE_EXCHANGE, true, false);
    }

    @Bean("couponReduceQueue")
    public Queue orderQueue() {
        return QueueBuilder.durable(QueueConstant.COUPON_REDUCE_QUEUE).build();
    }

    @Bean("couponReduceBinding")
    public Binding orderBinding(@Qualifier("couponReduceQueue") Queue queue, @Qualifier("couponReduceExchange")Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(QueueConstant.COUPON_REDUCE_ROUTING_KEY).noargs();
    }


}
